package com.ruoyi.service;

import com.ruoyi.dto.ResponseDTO;
import com.ruoyi.mapper.OrderMapper;
import com.ruoyi.pojo.OrderGood;
import com.ruoyi.pojo.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public ResponseDTO getAllOrder() {
        List<Orders> orders=orderMapper.getAllOrder();
        return ResponseDTO.success(orders);
    }

    @Override
    public ResponseDTO getGoodByOrder(Integer id) {
        List<OrderGood> orderGoods=orderMapper.getGoodByOrder(id);
        return ResponseDTO.success(orderGoods);
    }

    @Override
    public ResponseDTO confirmOrder(Integer id, String state) {
        int res=orderMapper.confirmOrder(id,state);
        if(res>0){
            return ResponseDTO.success("出餐成功");
        }
        else{
            return ResponseDTO.error("出餐失败");
        }
    }

    @Override
    public ResponseDTO getPhoneNumber(Integer id) {
        String phoneNumber=orderMapper.getPhoneNumber(id);
        return ResponseDTO.success(phoneNumber);
    }
}
